package cn.yangliu.jdbc.dymanicdb;

import cn.yangliu.comm.tools.StringUtils;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * @author Xiong Hao
 */
public class DynamicDataSourceResolver extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        String key = DataSourceContextHolder.getDataSourceType();
        if (StringUtils.isEmpty(key)) {
            return DataSourceEnum.DEFAULT.getTarget();
        }
        return key;
    }
}
